﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using NHibernate;
using FluentNHibernate.Data;

namespace BankCreditPortfolio.DAL.Entities
{
    public class TariffPersistence
    {
        public virtual int TariffId { get; set; }
        public virtual string Title { get; set; }
        public virtual int NumberOfGuarantors { get; set; }
        public virtual string Description { get; set; }
        public virtual decimal FirstPayment { get; set; }
        public virtual decimal OtherPayments { get; set; }
        public virtual decimal Min { get; set; }
        public virtual decimal Max { get; set; }
        public virtual int CreditPercent { get; set; }
        public virtual DateTime Time { get; set; }
        public virtual Currency Currency { get; set; }
        public virtual float Fine { get; set; }
        public virtual int EarlyRepaymentFine { get; set; }
        public virtual bool Used { get; set; }
    }

    public class Tariff : TariffPersistence
    {
        public IList<DocumentType> Documents { get; private set; }

        public Tariff()
        {
            this.Documents = new List<DocumentType>();
        }

        public string ThisInfo
        {
            get { return this.TariffId + "...---...---...---..." + this.NumberOfGuarantors + "...---...---...---..." + this.Description; }
        }
    }

    public class TariffMap : ClassMap<TariffPersistence>
    {
        public TariffMap()
        {
            Id(x => x.TariffId).GeneratedBy.HiLo("tariff");
            Id(x => x.TariffId).Unique();
            Map(x => x.NumberOfGuarantors);
            Map(x => x.Description);
            Map(x => x.FirstPayment);
            Map(x => x.OtherPayments);
            Map(x => x.Min);
            Map(x => x.Max);
            Map(x => x.Time);
            Map(x => x.CreditPercent);
            Map(x => x.Title);
            Map(x => x.Fine);
            Map(x => x.EarlyRepaymentFine);
            Map(x => x.Used);
            References(x => x.Currency).Column("CurrencyId");
            Table("Tariff");
        }
    }
}
